package cn.yu.meeting.meeting.controller;

import cn.yu.meeting.common.pojo.PageBean;
import cn.yu.meeting.common.pojo.Result;
import cn.yu.meeting.meeting.pojo.MeetingListItem;
import cn.yu.meeting.meeting.service.MeetingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/meeting")
public class MeetingController {


    @Autowired
    private MeetingService meetingService;

    /**
     * 获取会议列表
     *
     * @param pageNum  页码
     * @param pageSize 每页数量
     * @return 会议列表
     */
    @GetMapping("/list")
    public Result<PageBean<MeetingListItem>> getMeetingList(@RequestParam Integer pageNum,
                                                            @RequestParam Integer pageSize) {
        PageBean<MeetingListItem> pageBean = meetingService.getMeetingList(pageNum, pageSize);
        return Result.success(pageBean);
    }

    /**
     * 添加会议
     *
     * @param tittle    会议标题
     * @param desc      会议描述
     * @param startTime 开始时间
     * @param endTime   结束时间
     */
    @PostMapping("/addMeeting")
    public Result addMeeting(@RequestBody String tittle,
                             @RequestBody String desc,
                             @RequestBody String startTime,
                             @RequestBody String endTime) {
        meetingService.addMeeting(tittle, desc, startTime, endTime);
        return Result.success();
    }
}
